﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OutPage_Role_Edit.aspx.cs" Inherits="SysManage_OutPage_Role_Edit" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>角色编辑</title>
    <base target ="_self" />
    <link rel="stylesheet" href ="../css/css.css" type="text/css" />
    <!--#include file="../JS/KeyControlCode.js"-->
    <!--#include file="../JS/TrimData.js"--> 
    
    <script language ="javascript" type="text/javascript" >
    <!--
function ck(obj,obj1)
{
    if(obj.lowsrc=="") return true;
    obj.imgRolln=obj.src;
    obj.src=obj.lowsrc;
    obj.lowsrc=obj.imgRolln;
    if(obj1.style.display=='none')
       obj1.style.display='';
    else
       obj1.style.display='none';
}

var GOrgInfo = "" ;
var GNextOrgID = "";      //本级及下级部门ID集合
var GNoRepeatOrgID = "";  //得到本级及下级不重复部门ID集合
var GPersCount = "0";     //当前树中所关联到的人员数;
var GOrgCount = "0";      //当前树中所关联到的组织数;
//显示树型

function showtree(space_c,ParentIDCol)
{
    //parent.form1.HChoiceOrgIDCol.value = "";   //清空上页面中的ID集合
    var aPCol = ParentIDCol.split(',');
    var iPcol = aPCol.length;
    for(m=0;m<iPcol;m++)
    {
      show_tree(space_c,aPCol[m]);
    }
}

function show_tree(space_c,ParentID)
{
  var i,j,k,img_src1,img_src2; 
  for(k=0;k<trees.length;k++)
  {
    if(trees[k].ParentID == ParentID || (trees[k].ChildNumber == "0" && trees[k].ID == ParentID ))
    {
      document.write("<table border=0 cellspacing=0 cellpadding=0 bordercolor=#000000 width=100%><tr><td>");      
      for(i=1;i<=space_c;i++)
        document.write("&nbsp;&nbsp;");
     
      img_src1="img/sys/open.gif";
      img_src2="img/sys/open.gif";
      /////////////////////////////////////////////
      GOrgCount = GOrgCount*1+1;
      document.write("<img lowsrc=" + img_src2 + " id=\"img_"+trees[k].ID+"\" onclick=\"ck(this,document.all.T" + trees[k].ID + ");\" src=" + img_src1 + " align=middle><label id=\"Lable1\"  style=\"cursor:pointer\" onclick=\"tog(this,'#ffffff');SpreadNextOrgTree('" + trees[k].ID + "','" + trees[k].ChildNumber +"') \" >&nbsp;" + trees[k].Name + "</label>&nbsp;<input type=\"checkbox\" name=\"chkPage\"  value=\"" + trees[k].ID + "\"  /></td></tr></table>");
      document.write ("<span id='T" + trees[k].ID + "' style='display:'>" );
      if(trees[k].ChildNumber != "0")
        show_tree(space_c +1 ,trees[k].ID);
      document.write ("</span>");
    }    
  }
}


function ClearItem()
{
    GNextOrgID = "";    
}
//取得同级及下级部门ID的集合.为选择人员做准备
function GetNextOrgID(OrgID)   
{
  var k;
  GNextOrgID = GNextOrgID + OrgID+",";
  for(k=0;k<trees.length;k++)
  {
    var TempStr = "";
    if(trees[k].ParentID == OrgID)   //当前组织的ID
    {
      TempStr = TempStr + trees[k].ID + ",";
      GetNextOrgID(trees[k].ID);
      GNextOrgID = GNextOrgID + TempStr ;
    }
  }
}

//去掉重复的数据
function DelRepeatData(sData)
{
   ClearItem();
   var ary = sData.split(',');
   var iary = ary.length;
   for(i=0;i<ary.length;i++)
   {
       var itype = 0;
       for (j=i+1;j<ary.length;j++)
       {
          if(ary[i] ==ary[j])
          {
            itype =1;
            break;
          }
       }
       if(itype == 0 && i!= iary-1)
       {
         GNextOrgID = GNextOrgID + ary[i] + ",";
       }
       else
       {
         itype =0;
       }
   }   
}


//展开收缩下一级部门
function SpreadNextOrgTree(DeptID,ChildNum)
{
  var i,j,k,img_src1,img_src2;
  if(ChildNum!="0")
  {
    if(eval("document.all.T"+DeptID+".style.display")=='none')
    {
      eval("document.all.T"+DeptID+".style.display=''");    //展开下级层
      eval("document.all.img_"+DeptID+".src=\"img/sys/open.gif\";");    //展开下级层
      eval("document.all.img_"+DeptID+".lowsrc=\"img/sys/close.gif\";");    //展开下级层
    }
    else
    {
      eval("document.all.T"+DeptID+".style.display='none'");    //收缩下级层
      eval("document.all.img_"+DeptID+".src=\"img/sys/close.gif\";");    //收缩下级层
      eval("document.all.img_"+DeptID+".lowsrc=\"img/sys/open.gif\";");    //收缩下级层
    }
  }
}
//取得上级部门ID的集合.为展开树做准备的.
function GetSuperOrgID(OrgID)   
{
  var k;
  for(k=0;k<trees.length;k++)
  {
    var TempStr = "";
    if(trees[k].ID == OrgID)   //当前组织的ID
    {
      TempStr = TempStr + trees[k].ID + ",";
      GetSuperOrgID(trees[k].ParentID);
      GOrgInfo = GOrgInfo + TempStr ;
    }
  }
}

    //展开一个新树
    function SpreadNewOrgTree()
    {  
      var i,j,k,img_src1,img_src2;
      if(GOrgInfo!="")
      {
        var ary  = GOrgInfo.split(',');
        var nary = ary.length;
        for(i=0;i<nary-1;i++)
        {
          eval("document.all.T"+ary[i]+".style.display=''");
        } 
      }
      else
      {
      }
    }

    var tgs; 
    var tmp_background_val; 
    function tog(n,flags)
    { 
      if (tgs)
      { 
        tgs.style.background= tmp_background_val ; 
      } 
      n.style.background= '#99ccff'; 
      tmp_background_val=flags;
      tgs=n; 
    } 
-->
    </script>

</head>
<body style =" background-image :url('../images/hit_bg.gif');">
<% 
  Response .ExpiresAbsolute=System.DateTime.Now. AddSeconds(-1);
  Response.Expires=0;
  Response.CacheControl = "no-cache";
%>
    <form id="form1" method ="post" runat="server">
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="15%" height="18" valign="top" background="../images/tablelb.gif" class="font13"> 
      <div align="left"><img height="18" src="../images/tablelbleft.gif" width="18" alt ="" /></div></td>
    <td width="2%" valign="top" background="../images/tablelb.gif" bgcolor="#ffffff" class="font13"> 
      <div align="right"><img height="18" src="../images/tablelbright.gif" width="12" alt ="" /></div></td>
    <td colspan="2" align="center" bgcolor="#ffffff" class="font13"> <div align="right"> 
      </div></td>
  </tr>
  <tr> 
    <td height="26" colspan="2" align="center" bgcolor="#e9ecf5" class="font13"> 
      <div align="center">角色管理</div></td>
    <td width="80%" height="26" valign="bottom" background="../images/tddi.gif" class="font13"> 
      <div align="right"> </div></td>
    <td width="3%" valign="top" background="../images/tddi.gif" class="font13"> 
      <div align="right"><img height="26" src="../images/tddir.gif" alt ="" /></div></td>
  </tr>
</table>
<table width="98%" height="107" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#e9ecf5">
  <tr> 
    <td height="147"  valign="top"> 
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="tablelsdi">
          <tr> 
            <td width="4%" background="../images/tablelb01.gif"><img src="../images/tablelb01-left.gif" width="21" height="22" alt ="" /></td>
            <td width="82%" background="../images/tablelb01.gif" class="font12w">角色编辑</td>
            <td width="14%" background="../images/tablelb01.gif"> <div align="right"><img src="../images/tablelb01-right.gif" width="21" height="22" alt ="" /></div></td>
          </tr>
        </table>
          <input type="hidden" id="PCount" runat ="server"  />
          <input type="hidden" id="BCount" />
          <input type="hidden" id="OrRoleCode" runat ="server" />
          <input type="hidden" id="OrRoleName" runat ="server" />
          <input type="hidden" id="hidPageIDList" runat ="server"  />
          <input type="hidden" id="hidBtnIDList" runat ="server"  />
          <input type="hidden" id="hidEditType" runat ="server" />
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="tablelb">
      <tr>
        <td width="10%" bgcolor="#E1EEFD" class="tableleft" align ="right" >角色代码&nbsp;</td>
         <td bgcolor="#E1EEFD" class="tableleft"><asp:TextBox ID="RoleCode" runat ="server" TabIndex ="1" MaxLength ="20" onkeydown = "Number(this)" ></asp:TextBox><asp:Label ID="tishi1" runat ="server" Text ="*" ForeColor="Red"></asp:Label></td>
      </tr>
      <tr>
        <td bgcolor="#ECF4FD" class="tableleft"  align ="right">角色名称&nbsp;</td>
        <td bgcolor="#ECF4FD" class="tableleft"><asp:TextBox ID="RoleName" runat ="server" TabIndex ="2" MaxLength ="20"></asp:TextBox><asp:Label ID="tishi2" runat ="server" Text ="*" ForeColor="Red"></asp:Label></td>
      </tr>
      <tr>
        <td bgcolor="#E1EEFD" class="tableleft" align ="right">角色描述&nbsp;</td><td bgcolor="#E1EEFD" class="tableleft"><asp:TextBox ID="RoleDescr" runat ="server" TabIndex ="3" TextMode ="multiLine" Rows ="3" Columns ="40"></asp:TextBox>*描述小于200字</td>
      </tr>
      <tr>
        <td bgcolor="#E1EEFD" class="tableleft"  align ="right">是否有效&nbsp;</td>
        <td bgcolor="#E1EEFD" class="tableleft">
           <asp:dropdownlist id="Effective" tabIndex="4" runat="server" Enabled="true" Width="60px">			
			 <asp:ListItem Value="1" Selected ="true" >是</asp:ListItem>
			 <asp:ListItem Value="0">否</asp:ListItem>
		  </asp:dropdownlist>
        </td>
      </tr>
      <tr style ="height :30px;">
        <td bgcolor="#ECF4FD" class="tableleft" align ="center" colspan ="2">
            <asp:Button ID="SaveInfo" runat="server" Text="Button" Width="0px" Height="0px" OnClick="SaveInfo_Click" />
            <input id="GrantBtn1" type="button" runat ="server"  class="button02"  value ="提交(s)" accesskey ="s"  onclick ="SaveAllInfo()" /> &nbsp;&nbsp;
            <input type ="button" id="backBtn" value ="返回(c)" accesskey ="c"   class="button02" onclick ="window.close();" />
       </td>
      </tr>
      <tr>
        <td valign ="top" bgcolor="#E1EEFD" class="tableleft" align ="right">&nbsp;&nbsp;&nbsp;&nbsp;授权项&nbsp;</td>
        <td bgcolor="#E1EEFD" class="tableleft"><%=sDeptHtml%></td>
      </tr>
      </table>
      </td>
      </tr>
      </table>    
    </form>
    <script language ="javascript" type="text/javascript" >
    <!--      
      var sData = dialogArguments;
      form1.hidEditType.value = sData.stype ;
      if(sData.stype == "2")  // 2 修改 1 新建
      {
       // window.document.all.DisplayUser.style.display= "";   
        var sobj = sData.RoleForm.Hcode.value;
        var ary=sobj.split('|'); 
        form1.RoleCode.value = trim(ary[0]);
        form1.OrRoleCode.value = trim(ary[0]);  //初始化时的角色代码

        form1.RoleName.value = trim(ary[1]);
        form1.OrRoleName.value = trim(ary[1]);   //初始化时的角色代码

        form1.RoleDescr.value = trim(ary[2]);
        form1.Effective.value = trim(ary[3]);
//        form1.ChoiceName_1.value = trim(ary[3]);
//        alert(ary);
        //选中已授权按钮  
        var sStr= trim(ary[4]);
        var ary=sStr.split(',');
        var nGrantCount=ary.length;  //授权个数
        var nPCount = form1.PCount.value;   //页面数 nGrantCount<=nPCount

        for(j=0;j<nGrantCount-1;j++)  //总个数
        {
          var GrantPageID = ary[j];

          for(i=0;i<=nPCount;i++)         //页面授权信息
          {
            var sStr2 = form1.chkPage[i].value;
            //var ary2 = sStr2.split('^');
            if(GrantPageID==sStr2)
            {
              form1.chkPage[i].checked=true;
            }
          }   
        }
      }
      else
      {       
          //window.document.all.DisplayUser.style.display= "none";   
      }   
      
      /////////////////////////////////////////////////////////////////////////////////
      function SavePageBtnInfo()
      {
         var PageCount = form1.PCount.value;
         var sPageIDList = "";  //页面集合
         if(PageCount == 1)
         {
             if(form1.chkPage.checked)
             {
               var sPageID = form1.chkPage.value;
               sPageIDList = sPageIDList + sPageID + ",";
             }
             form1.hidPageIDList.value = sPageIDList;
         }
         else
         {
           for(i=0;i<=PageCount;i++)
           {
             if(form1.chkPage[i].checked)
             {
               var sPageID=form1.chkPage[i].value;
               if(!isContained(sPageID,sPageIDList,","))
                 sPageIDList = sPageIDList + sPageID + ",";
              }
            }
            form1.hidPageIDList.value = sPageIDList;
         }
         

         //alert(form1.hidPageIDList.value);
         //alert(form1.hidBtnIDList.value+'*'+form1.hidBtnIDList.value)
      }
      
      //保存按钮
      function SaveAllInfo()
      {
          if(form1.RoleCode.value == "")
           {
               alert("角色代码不能为空");
               return;
           }
           if(form1.RoleName.value == "")
           {
               alert("角色名称不能为空");
               return;
           }
           if(form1.RoleDescr.value.length >200)
           {
               alert("角色描述不能超过200个字!");
               return;
           }           
           SavePageBtnInfo();
           
           if(form1.hidPageIDList.value == "" || form1.hidPageIDList.value == null)
           {
               alert("请选择授权信息");
               return;
           }
           else
           {
               var ssave=window.document.getElementById("SaveInfo");
		       if(ssave!=null)
		          ssave.click();
		   }       
      }
    -->
    </script>
</body>
</html>
